import {
  createRouter,
  createWebHistory
} from 'vue-router'
import Home from '../views/Home.vue'
import CityList from '../views/CityList.vue'
import AddCity from '../views/AddCity.vue'

const routes = [{
    path: '/',
    name: 'home',
    redirect: '/home'
  },
  {
    path: '/home/:cityCode?',
    name: 'Home',
    component: Home,
    meta: {
      index: 1
    },
    props: true
  },
  {
    path: '/city-list',
    name: 'CityList',
    component: CityList,
    meta: {
      index: 2
    }
  },
  {
    path: '/add-city',
    name: 'AddCity',
    component: AddCity,
    meta: {
      index: 3
    }
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router